{% extends "base.html" %}
{% block title %}TaskProfile{% endblock %}
{% block content %}
<!--atsystem-->
                <!--/span-->
                <div  class="span9" id="content">
                      <!-- morris stacked chart -->


                    <div class="row-fluid">
                                <div class="navbar">
                                <div class="navbar-inner">
                                        <ul class="breadcrumb">
                                            <i class="icon-chevron-left hide-sidebar"><a href='#' title="Hide 
Sidebar" rel='tooltip'>&nbsp;</a></i>
                                            <i class="icon-chevron-right show-sidebar" style="display:none;"><
a href='#' title="Show Sidebar" rel='tooltip'>&nbsp;</a></i>
                                            <li>
                                                <a href="/admin/">Dashboard</a> <span class="divider">/</span>
                                            </li>
                                            <li>
                                                <a href="/admin/tasks/">Tasks</a> <span class="divider">/</span>
                                            </li>
                                            <li>
                                                <a href="/admin/tasks/profile/{{task.id}}">{{task.name}}</a> <span class="div
ider">/</span>
                                            </li>


                                        </ul>
                                </div>
                                </div>
                        </div>















			<div class="row-fluid">
                         <!-- block -->
                        <div class="block">
                            <div class="navbar navbar-inner block-header">
                                <div id="idusername" value="{{task.name}}" class="muted pull-left"><b>{{task.name}} Profile</b></div>
                            </div>
                            <div class="block-content collapse in">
                                <div class="span12">
                                        <!-- BEGIN FORM-->
                                        <form action="#" id="form_sample_1" class="form-horizontal">
                                                <fieldset>
                                                        <div class="alert alert-error hide">
                                                                <button class="close" data-dismiss="alert"></button>
                                                                You have some form errors. Please check below.
                                                        </div>
                                                        <div class="alert alert-success hide">
                                                                <button class="close" data-dismiss="alert"></button>
                                                                Your form validation is successful!
                                                        </div>
                                                        <div class="control-group">
                                                                <label class="control-label"><b>TaskName</b><span class="required">*</span></label>
                                                                <div class="controls">
                                                                        <input type="text" id="taskname" data-required="1" class="input-xlarge focused" readOnly='true'  value="{{task.name}}"/>
                                                                </div>
                                                        </div>
                                                        <div class="control-group">
                                                                <label class="control-label"><b>Task</b><span class="required">*</span></label>
                                                                <div class="controls">
                                                                        <input id="email" type="text" class="input-xlarge focused" readOnly='true' value="{{task.task}}"/>
                                                                </div>
                                                        </div>




 <div class="control-group">
                                          <label class="control-label" for="optionsCheckbox"><b>enabled</b></label>
                                          <div class="controls">
                                            <label class="uniform">
                                              <input class="uniform_on" type="checkbox" id="t_enabled" value="option1" $(function())>
                                            </label>
                                          </div>
                                        </div>



<!--
                                        <div class="control-group">
                                          <label class="control-label" for="selectError"><b>Discover Task</b></label>
                                          <div class="controls">
                                            <select id="selectgroup">
                                              <option value="">-------------------</option>
                                            {% for d_task in disco_task %}
                                              <option value="{{d_task}}">{{d_task}}</option>
                                            {% endfor %}
                                            </select>
                                            <span class="help-inline">Woohoo!</span>
                                          </div>
                                        </div>-->


                                        <div class="control-group">
                                          <label class="control-label" for="selectError"><b>interval</b></label>
                                          <div class="controls">
                                            <select id="selectinter">
                                              <option value="{{task.interval_id}}">{{task.interval}}</option>
                                             {% if task.interval_id  %}
						 <option value="None">None</option>
					     {% endif %}
                                            {% for inter in interval %}
                                              <option value="{{inter.id}}">{{inter}}</option>
                                            {% endfor %}
                                            </select>
                                            <span class="help-inline">Woohoo!</span>
                                          </div>
                                        </div>



                                        <div class="control-group">
                                          <label class="control-label" for="selectError"><b>crontab</b></label>
                                          <div class="controls">
                                            <select id="selectcron">
                                              <option value="{{task.crontab_id}}">{{task.crontab}}</option>
                                             {% if task.crontab_id  %}
                                              <option value="None">None</option>
						{% endif %}
                                            {% for cron in crontab %}
                                              <option value="{{cron.id}}">{{cron}}</option>
                                            {% endfor %}
                                            </select>
                                            <span class="help-inline">Woohoo!</span>
                                          </div>
                                        </div>



                                                        <div class="form-actions">
                                                                <button type="button" onclick="updata()" class="btn btn-primary">update</button>
                                                                <button  onclick="javascript:history.go(-1);" type="button" class="btn">Cancel</button>
                                                        </div>
                                                </fieldset>
                                        </form>
                                        <!-- END FORM-->
                                </div>
                            </div>
                        </div>


                        <!-- /block -->
                    </div>
</div>


                     <!-- validation -->
            </div>

<script "text/javascript">

function updata(){
var inter=$('#selectinter option:selected') .val();
var cron=$('#selectcron option:selected') .val();
if($("#t_enabled").is(':checked')){
var enabled='True';
}
else{
var enabled='False';
}
if(inter != "None" && cron != "None"){
alert('Only one of interval or crontab must be set');
}
else if(inter == "None" && cron == "None"){
alert('One of interval or crontab must be set.');
}
else{

var array1=new Array();
array1.push({{task.id}});
array1.push(enabled);
array1.push(inter);
array1.push(cron);

//alert(array1);
//}
$.post('/admin/tasks/update/',
{
'arraydata':JSON.stringify(array1)
},

function(data){
alert(data);
});
}
}
$(function init(){
if('{{task.enabled}}' == 'True'){
console.log(document.getElementById("t_enabled").checked =true);
}

});
</script>

{% endblock %}



